package tests;

import model.ProgramGraph;
import model.TransitionSystem;

/** Class for testing a creation of graphs with/without variables
 * @author DarkoLaptop2
 *
 */
public class GraphTester {

	/** Main method for testing
	 */
	public static void main(String[] args) {
		
		System.out.println("TESTING GRAPH WITHOUT VARIABLES");
		//Testing graphs without variables
		TransitionSystem TSgraph=new TransitionSystem();
		//Adding new nodes
		TSgraph.addNode(0, "A");
		TSgraph.addNode(1, "B");
		TSgraph.addNode(2, "C");
		TSgraph.addNode(3, "D");
		//Adding new transitions
		TSgraph.addEdge(0, "jade", 2);
		TSgraph.addEdge(0, "jade", 1);
		TSgraph.addEdge(2, "spie", 3);
		TSgraph.addEdge(2, "hrci", 1);
		//Removiong Nodes
//		TSgraph.removeNode(2);
		TSgraph.removeNode(3);
//		TSgraph.removeNode(0);
		//Printing graph information with transitions information
		System.out.println(TSgraph.toStringTransitionPrint());
		//Printing parents of a node with given index
		System.out.println("Parents for node with index 1:");
		System.out.println(TSgraph.getNodeParents(1));
		//Changing transition type
		TSgraph.setTransitionType("jade", false);
		//lets try with a transition name that doesn't exist
		TSgraph.setTransitionType("hrki", false);
		//Printing all transitions
		System.out.println("All transitions:");
		for(String transtionName:TSgraph.getAllTransitions())
			System.out.println(transtionName);
		//Printing graph uncontrollable transitions
		System.out.println("Transitions that are uncontrollable");
		for(String transtionName:TSgraph.getAllUncontrollableTransitions())
			System.out.println(transtionName);
		
		System.out.println("***********************************");
		System.out.println("TESTING GRAPH WITH VARIABLES");
		//Testing program graphs
		ProgramGraph Pgraph=new ProgramGraph();
		
		//Adding new nodes
		Pgraph.addNode(0, "X");
		Pgraph.addNode(1, "Y");
		Pgraph.addNode(2, "Z");
		//Adding new transitions 
		Pgraph.addEdge(0, "x<3", "x=x+1", "jade", 1);
		Pgraph.addEdge(0, "x>1", "x=x+2", "gricka", 2);
		Pgraph.addEdge(1, "x>2", "x=x-2", "trebi", 2);
		Pgraph.addEdge(1, "x>0", "x=x+1", "pece", 1);
		//Changing transition type
		Pgraph.setTransitionType("trebi", false);
		//lets try with a transition name that doesn't exist
		Pgraph.setTransitionType("jadi", false);
		//Printing graph information with transition information
		System.out.println(Pgraph.toStringTransitionPrint());
		//Printing graph transitions
		System.out.println("All transitions:");
		for(String transtionName:Pgraph.getAllTransitions())
			System.out.println(transtionName);
		//Printing graph uncontrollable transitions
		System.out.println("Transitions that are uncontrollable");
		for(String transtionName:Pgraph.getAllUncontrollableTransitions())
			System.out.println(transtionName);
		
	}

}
